package com.haidechizi.leetcode;

public class _55_跳跃游戏 {

    public boolean canJump(int[] nums) {
        int maxIndex = 0;
        int currentIndex = 0;
        while (currentIndex < maxIndex + nums[maxIndex] && currentIndex < nums.length) {
            if (currentIndex + nums[currentIndex] > maxIndex + nums[maxIndex]) {
                maxIndex = currentIndex;
            }
            currentIndex++;
        }
        if (nums[maxIndex] + maxIndex >= nums.length) {
            return true;
        }
        return false;

    }

}
